package queries;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import entitys.Type;
import enums.Result;

public class UpdateSale {

	
	public static Result exe(String s,java.sql.Connection conn)
	{
		Statement stmt;
			try {
				
				int startindex=s.indexOf('@');
				int saleID = Integer.parseInt(s.substring(1,startindex));
				int active = Integer.parseInt(s.substring(startindex+1,s.length()));
				
				
				stmt = conn.createStatement();
				stmt.executeUpdate("UPDATE ccrm.marketingsales SET isActive="+active+" WHERE id="+saleID+";");
				
				return Result.OK;
				
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				System.out.println("Error in retrieving categories");
				return Result.ERROR;
			}
			
			
		
		
	}
}
